<template>
    <div class="head-wrapper clearfix">
        <!--头部的内容部分-->
        <div class="head clearfix">
            <div class="logo-wrapper">
                <router-link to="/home">
                    <img src="@/assets/img/logo.png" />
                </router-link>
            </div>
            <ul class="head-nav">
                <li>
                    <router-link to="/userspace/personal">我的主页</router-link>
                </li>
                <li>
                    <router-link to="/home">市场首页</router-link>
                </li>
                <li class="addable-item1 clearfix">
                    <a href="javascript:">
                        <span>账号</span>
                        <i class="iconfont icon-xialajiantouxiao"></i>
                    </a>
                    <ul class="addpage">
                        <router-link to="/userspace/personal">
                            <li>个人信息</li>
                        </router-link>
                        <router-link to="/userspace/settings/editPwd">
                            <li>账户安全</li>
                        </router-link>
                        <a href="javascript:">
                            <li>账号绑定</li>
                        </a>
                    </ul>
                </li>
                <li class="addable-item2 clearfix">
                    <a href="javascript:">
                        <span>评价</span>
                        <i class="iconfont icon-xialajiantouxiao"></i>
                    </a>
                    <ul class="addpage">
                        <a href="javascript:">
                            <li>我发出的</li>
                        </a>
                        <a href="javascript:">
                            <li>我收到的</li>
                        </a>
                        <a href="javascript:">
                            <li>待评价</li>
                        </a>
                    </ul>
                </li>
            </ul>
            <div class="head-search">
                <form action="javascript:">
                    <input type="text" class="search-text" v-model="keyword" />
                    <input type="submit" value="搜索" @click="goSearch" />
                </form>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            keyword: "",
        };
    },
    methods: {
        goSearch() {
            if (!this.keyword.trim()) {
                alert("搜索框不能为空");
                return;
            }
            this.$router.push({
                name: "search",
                params: {
                    keyword: this.keyword,
                },
            });
        },
    },
};
</script>

<style scoped>
a {
    text-decoration: none;
    color: #333333;
    user-select: none;
}
/*设置小箭头的左外边距*/
.icon-xialajiantouxiao {
    margin-left: 10px;
}
/*设置头部的样式*/
.head-wrapper {
    width: 100%;
    height: 80px;
    background-color: white;
    position: relative;
    z-index: 99;
}
/*设置头部内容区的大小和位置*/
.head-wrapper .head {
    width: 1200px;
    height: 100%;
    margin: 0 auto;
}
/*设置头部logo的大小和位置使其居中*/
.head .logo-wrapper {
    float: left;
    margin: 15px 0;
}

.logo-wrapper a,
.logo-wrapper img {
    display: block;
    width: 180px;
    height: 50px;
}

/*设置头部导航区*/
.head .head-nav {
    position: relative;
    float: left;
    width: 600px;
    margin-left: 80px;
}

/*设置导航区条目位置*/
.head .head-nav > li {
    float: left;
    margin-top: 30px;
    margin-left: 20px;
    font-size: 17px;
    line-height: 20px;
}

/*设置两个下拉条的样式*/
/*通过设置可下拉项目的padding属性做到撑开父元素的效果*/
.head .head-nav .addable-item1 > a,
.head .head-nav .addable-item2 > a {
    display: block;
    padding: 0 10px 5px;
}

.head .head-nav .addable-item1 {
    background-color: white;
    border: 1px solid transparent;
    height: 20px;
    overflow: hidden;
    margin-top: 22px;
    padding: 8px 0;
    border-top: none;
    position: absolute;
    left: 170px;
    transition: height 0.3s;
}

.head .head-nav .addable-item2 {
    background-color: white;
    border: 1px solid transparent;
    height: 20px;
    overflow: hidden;
    margin-top: 22px;
    padding: 8px 0;
    border-top: none;
    position: absolute;
    left: 260px;
    transition: height 0.3s;
}

.head .head-nav .addpage a {
    font-size: 14px;
    display: block;
    padding: 5px 10px;
}
.head .head-nav .addpage a:hover {
    background-color: rgb(245, 245, 245);
    color: rgb(91, 81, 69);
}

/*设置下拉条的展开*/
.head .head-nav .addable-item1:hover,
.head .head-nav .addable-item2:hover {
    height: 116px;
    border-color: rgb(204, 204, 204);
    box-shadow: 0 5px 5px rgba(0, 0, 0, 0.3);
}

/*设置下拉条展开时原本标题的样式变化*/
.head .head-nav .addable-item1:hover > a,
.head .head-nav .addable-item2:hover > a {
    color: rgb(91, 81, 69);
    font-weight: bold;
}

/*设置头部导航区超链接聚焦样式*/
.head .head-nav a:hover {
    color: #f30213;
}

/*设置头部搜索框样式*/
.head .head-search {
    float: right;
    background-color: rgb(232, 44, 41);
    border: 2px solid rgb(232, 44, 41);
    margin-top: 22px;
}

/*去除搜索框和搜索按键之间的空格*/
.head-search .search-text,
.search-text + input {
    float: left;
}

/*设置搜索框的样式*/
.head-search .search-text {
    font-size: 14px;
    line-height: 20px;
    padding: 8px 14px;
    border: none;
    outline: none;
}

/*设置搜索框旁按钮的样式*/
.head-search .search-text + input {
    color: #f4f4f4;
    border: none;
    height: 36px;
    width: 70px;
    font-size: 15px;
    background-color: transparent;
}
</style>